package com.dream.inspect.modules.business.controller;

import java.util.Arrays;
import java.util.Map;

import com.dream.inspect.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.dream.inspect.modules.business.entity.SuperviseImageEntity;
import com.dream.inspect.modules.business.service.SuperviseImageService;
import com.dream.inspect.common.utils.PageUtils;
import com.dream.inspect.common.utils.R;



/**
 * 督察照片表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-06-16 17:04:54
 */
@RestController
@CrossOrigin
@RequestMapping("business/superviseimage")
public class SuperviseImageController {
    @Autowired
    private SuperviseImageService superviseImageService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("business:superviseimage:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = superviseImageService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("business:superviseimage:info")
    public R info(@PathVariable("id") Long id){
        SuperviseImageEntity superviseImage = superviseImageService.selectById(id);

        return R.ok().put("superviseImage", superviseImage);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("business:superviseimage:save")
    public R save(@RequestBody SuperviseImageEntity superviseImage){
        superviseImageService.insert(superviseImage);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("business:superviseimage:update")
    public R update(@RequestBody SuperviseImageEntity superviseImage){
        ValidatorUtils.validateEntity(superviseImage);
        superviseImageService.updateAllColumnById(superviseImage);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("business:superviseimage:delete")
    public R delete(@RequestBody Long[] ids){
        superviseImageService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
